#define _CRT_SECURE_NO_WARNINGS



#include<iostream>
#include<string>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--)
    {
        string s;
        cin >> s;
        int cnt[10] = { 0 };
        for (int i = 0; i < s.size(); i++)
        {
            cnt[s[i] - '0']++;
        }
        if (s.size() == 1)
        {
            if (cnt[4] != 0 || cnt[8] != 0)
            {
                cout << "YES" << endl;
                continue;
            }
        }
        if (cnt[1] != 0 || cnt[3] != 0 || cnt[5] != 0 || cnt[7] != 0 || cnt[9] != 0)
        {
            if (cnt[2] != 0 || cnt[6] != 0)
            {
                cout << "YES" << endl;
                continue;
            }
        }
        if (cnt[2] != 0 || cnt[6] != 0)
        {
            if (cnt[4] != 0 || cnt[8] != 0)
            {
                cout << "YES" << endl;
                continue;
            }
        }
        if (cnt[4] != 0)
        {
            if (cnt[4] > 1 || cnt[8] != 0)
            {
                cout << "YES" << endl;
                continue;
            }
        }
        if (cnt[8] != 0)
        {
            if (cnt[8] > 1 || cnt[4] != 0)
            {
                cout << "YES" << endl;
                continue;
            }
        }
        cout << "NO" << endl;
    }
    return 0;
}

